package com.example.fw;

import org.openqa.selenium.By;

import com.example.tests.ContactData;

public class ContactHelper extends HelperBase {

	public ContactHelper(ApplicationManager manager) {
		super(manager);
	}
	public void initContactCreation() {
		click(By.linkText("add new"));
	}

	public void fillContactForm(ContactData contact){
		type(By.name("firstname"), contact.firstname);
		type(By.name("lastname"), contact.lastname);
		type(By.name("address"), contact.address);
		type(By.name("home"), contact.homePhone);
		type(By.name("mobile"), contact.mobilePhone);
		type(By.name("work"), contact.workPhone);
		type(By.name("email"), contact.email);
		type(By.name("email2"), contact.email2);
	    selecetByText(By.name("bday"), contact.birthDay);
	    selecetByText(By.name("bmonth"), contact.birthMonth);
	    type(By.name("byear"), contact.birthYear);
	    type(By.name("address2"), contact.address2);
	    type(By.name("phone2"), contact.phone2);
	}
	

	public void submitContactCreation() {
		click(By.name("submit"));	
	}

	public void returnToHomePage() {
		click(By.linkText("home page"));	
	}
	
	public void deleteContact(int index) {
		click (By.xpath("//input[@name='selected[]'][" + index + "]"));
		click (By.xpath("//*[@id='maintable']/tbody/tr[2]/td[7]/a/img"));
		click (By.xpath("//input[@value='Delete']"));
	}
		
	public void initContactPage(int a) {
		click (By.xpath("//input[@name='selected[]'][" + a + "]"));
		click (By.xpath("//*[@id='maintable']/tbody/tr[2]/td[7]/a/img"));
	}

	public void submitContactModification() {
		click (By.xpath("//input[@value='Update']"));
	}

}
